package com.bruceewu.galleryphoto.view;

import android.text.TextUtils;

import com.bruceewu.configor.entity.HolderEntity;
import com.bruceewu.configor.holder.base.CusBaseHolder;

import java.util.ArrayList;
import java.util.List;

public enum AppHolders {
    Test("test", TestHolder.class);

    private final String showType;
    private final Class<? extends CusBaseHolder> clazz;

    AppHolders(String showType, Class<? extends CusBaseHolder> clazz) {
        this.showType = showType;
        this.clazz = clazz;
    }

    public String showType() {
        return showType;
    }

    public static List<HolderEntity> getHolders() {
        List<HolderEntity> result = new ArrayList<>();
        AppHolders[] holders = AppHolders.values();
        for (AppHolders holder : holders) {
            result.add(new HolderEntity(holder.showType, holder.clazz));
        }
        return result;
    }

    public static AppHolders parse(String showType) {
        AppHolders[] holders = AppHolders.values();
        for (AppHolders holder : holders) {
            if (TextUtils.equals(holder.showType, showType)) {
                return holder;
            }
        }
        return AppHolders.Test;
    }
}
